package com.door.erp.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.door.erp.enums.OrderStatus;

/**
 * 订单
 * @author yangxuelin
 */
@Entity
@Table(name = "orders", catalog = "door")
public class Orders implements Serializable {

	private static final long serialVersionUID = -5666602087720099711L;

	private long id;
	
	private String orderNo;
	
	private List<OrderItem> items;
	
	private Client client;
	
	private Set<OutputOrder> outputOrders;
	
	private SellOrder sellOrder;
	
	private double ensureMoney;
	
	private double discount;
	
	private Date createTime;
	
	private OrderStatus status;
	
	private String remark;

	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	
	@Column(name="orderNo",unique = true, nullable = false)
	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	@OneToMany(mappedBy="order", targetEntity=OrderItem.class,cascade=CascadeType.ALL)
	public List<OrderItem> getItems() {
		return items;
	}

	public void setItems(List<OrderItem> items) {
		this.items = items;
	}

	@OneToOne
	@JoinColumn(name="clientId", nullable=false)
	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	@OneToMany(mappedBy="orders")
	public Set<OutputOrder> getOutputOrders() {
		return outputOrders;
	}

	public void setOutputOrders(Set<OutputOrder> outputOrders) {
		this.outputOrders = outputOrders;
	}

	@OneToOne(mappedBy="order")
	public SellOrder getSellOrder() {
		return sellOrder;
	}

	public void setSellOrder(SellOrder sellOrder) {
		this.sellOrder = sellOrder;
	}
	
	@Column(name="ensureMoney")
	public double getEnsureMoney() {
		return ensureMoney;
	}

	public void setEnsureMoney(double ensureMoney) {
		this.ensureMoney = ensureMoney;
	}

	@Column(name="discount")
	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	@Column(name="createTime", nullable=false, updatable=false)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@Column(name = "status")
	public OrderStatus getStatus() {
		return status;
	}

	public void setStatus(OrderStatus status) {
		this.status = status;
	}

	@Column(name="remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
